import { IPSAppView } from './ipsapp-view';
import { IPSAppViewRef } from './ipsapp-view-ref';
import { IPSNavigateContext } from '../../control/ipsnavigate-context';
import { IPSNavigateParam } from '../../control/ipsnavigate-param';
import { IPSLanguageRes } from '../../res/ipslanguage-res';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSAppViewRefImpl extends PSModelObjectImpl implements IPSAppViewRef {
  get codeName(): string {
    return this.M.codeName;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get height(): number {
    return this.M.height != null ? this.M.height : 0;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  get openMode(): string {
    return this.M.openMode;
  }

  get owner(): IModel {
    return this.M.owner;
  }

  protected psnavigatecontexts: IPSNavigateContext[] | null = null;

  getPSNavigateContexts(): IPSNavigateContext[] | null {
    if (this.psnavigatecontexts == null) {
      this.psnavigatecontexts = this.fillChildListModel(this.M.getPSNavigateContexts, 'control.IPSNavigateContext') as IPSNavigateContext[];
    }
    return this.psnavigatecontexts;
  }

  get psNavigateContexts(): IPSNavigateContext[] | null {
    return this.getPSNavigateContexts();
  }

  findPSNavigateContext(objKey: any): IPSNavigateContext | null {
    return this.getPSModel5('control.IPSNavigateContext', this.getPSNavigateContexts(), objKey) as IPSNavigateContext;
  }

  protected psnavigateparams: IPSNavigateParam[] | null = null;

  getPSNavigateParams(): IPSNavigateParam[] | null {
    if (this.psnavigateparams == null) {
      this.psnavigateparams = this.fillChildListModel(this.M.getPSNavigateParams, 'control.IPSNavigateParam') as IPSNavigateParam[];
    }
    return this.psnavigateparams;
  }

  get psNavigateParams(): IPSNavigateParam[] | null {
    return this.getPSNavigateParams();
  }

  findPSNavigateParam(objKey: any): IPSNavigateParam | null {
    return this.getPSModel5('control.IPSNavigateParam', this.getPSNavigateParams(), objKey) as IPSNavigateParam;
  }

  get parentDataJO(): IModel {
    return this.M.parentDataJO;
  }

  get realOpenMode(): string {
    return this.M.realOpenMode;
  }

  get realTitle(): string {
    return this.M.realTitle;
  }

  protected realtitlepslanguageres: IPSLanguageRes | null = null;

  getRealTitlePSLanguageRes(): IPSLanguageRes | null {
    if (this.realtitlepslanguageres != null) return this.realtitlepslanguageres;
    const value = this.M.getRealTitlePSLanguageRes;
    if (value == null) {
      return null;
    }
    this.realtitlepslanguageres = this.getPSModel4('res.IPSLanguageRes', value, 'getRealTitlePSLanguageRes') as IPSLanguageRes;
    return this.realtitlepslanguageres;
  }

  get realTitlePSLanguageRes(): IPSLanguageRes | null {
    return this.getRealTitlePSLanguageRes();
  }

  getRealTitlePSLanguageResMust(): IPSLanguageRes {
    const value = this.getRealTitlePSLanguageRes();
    if (value == null) {
      throw new Error('未指定引用视图标题语言资源');
    }
    return value;
  }

  protected refpsappview: IPSAppView | null = null;

  getRefPSAppView(): IPSAppView | null {
    if (this.refpsappview != null) return this.refpsappview;
    const value = this.M.getRefPSAppView;
    if (value == null) {
      return null;
    }
    this.refpsappview = this.getPSModel4('app.view.IPSAppView', value, 'getRefPSAppView') as IPSAppView;
    return this.refpsappview;
  }

  get refPSAppView(): IPSAppView | null {
    return this.getRefPSAppView();
  }

  getRefPSAppViewMust(): IPSAppView {
    const value = this.getRefPSAppView();
    if (value == null) {
      throw new Error('未指定引用视图');
    }
    return value;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get viewParamJO(): IModel {
    return this.M.viewParamJO;
  }

  get width(): number {
    return this.M.width != null ? this.M.width : 0;
  }

  get cls(): string {
    return 'PSAppViewRefImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'app.view.IPSAppViewRef' || cls == 'control.IPSNavigateParamContainer') return true;
    return super.instanceof(cls);
  }
}
